import { reactive, toRaw, ToRefs, toRefs } from "vue";
import ComponentController, { GetMethods, GetState } from '@/common/controller';
import DashboardApi from '@/api/dashboard'
import {DashboardStatisData} from '@/api/dashboard/types'
class Controller extends ComponentController {
	state: {data:DashboardStatisData};
	constructor(){
		super();
		this.state=reactive({
			data:{
				shop_count:0,
				shop_start_time:"",
				shop_end_time:"",
				sales_amount:0,
				bonus_amount:0,
				amount_start_time:"",
				amount_end_time:"",
			}
		})
	}
	getState() {
		return {
			...toRefs(this.state),
		}
	}
	getMethods() {
		return {
			getData:this.getData.bind(this),
		}
	}

	private getData(){
		DashboardApi.getStatisData().then(res=>{
			this.state.data=res.data
		})
	}
}

export default Controller
